package com.ej.web.controller.ej.app;

import com.ej.busi.dto.course.EjUserCourseDetailDto;
import com.ej.busi.dto.course.EjUserCourseDto;
import com.ej.busi.dto.course.EjUserCourseStatisticsDto;
import com.ej.busi.service.IEjUserCourseService;
import com.ej.common.core.controller.BaseController;
import com.ej.common.core.domain.AjaxResult;
import com.ej.common.dto.BasePieChartDataDto;
import io.swagger.annotations.Api;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * 【用户课程】Controller
 *
 * @author ej
 * @date 2025-08-11
 */
@RestController
@RequestMapping("/ej/app/userCourse")
@Api("【用户课程】Controller")
public class EjAppUserCourseController extends BaseController {

    @Autowired
    private IEjUserCourseService userCourseService;

    /**
     * 获取用户已购买课程列表
     * @param subjectId
     * @param courseName
     * @return
     */
    @RequestMapping("/userCourseList")
    private AjaxResult<List<EjUserCourseDto>> userCourseList(@RequestParam("subjectId") Long subjectId, @RequestParam("courseName")String courseName){
        return AjaxResult.success(userCourseService.userCourseList(subjectId, courseName));
    }

    /**
     * 获取用户某个已购买课程统计
     * @param courseId
     * @return
     */
    @RequestMapping("/userCourseStatistics")
    private AjaxResult<EjUserCourseStatisticsDto> userCourseStatistics(@RequestParam("courseId") Long courseId){
        return AjaxResult.success(userCourseService.userCourseStatistics(courseId));
    }

    /**
     * 获取用户某个课程章节列表
     * @param courseId
     * @return
     */
    @RequestMapping("/userCourseChapter")
    private AjaxResult<List<BasePieChartDataDto>> userCourseChapter(@RequestParam("courseId") Long courseId){
        return AjaxResult.success(userCourseService.userCourseChapter(courseId));
    }

    /**
     * 获取用户某个课程章节课时列表
     * @param courseId
     * @return
     */
    @RequestMapping("/userCourseChapterPeriod")
    private AjaxResult<List<BasePieChartDataDto>> userCourseChapterPeriod(@RequestParam("courseId") Long courseId){
        return AjaxResult.success(userCourseService.userCourseChapter(courseId));
    }

    /**
     * 获取用户某个课程详情
     * @param courseId
     * @return
     */
    @RequestMapping("/userCourseDetail")
    private AjaxResult<EjUserCourseDetailDto> userCourseDetail(@RequestParam("courseId") Long courseId){
        return AjaxResult.success(userCourseService.userCourseDetail(courseId));
    }

}
